import { defineStore } from "pinia"
import { ref } from 'vue'

export const useUserStore = defineStore(
  'todo-user',
  () => {
    const token = ref('')
    const setToken = (t) => {
      token.value = t
    }
    // 用户名，用来做查询用户id的关键字
    const username = ref('')
    const setUsername = (t) => {
      username.value = t
    }
    // 注册后获取用户id
    const userId = ref('')
    const setUserId = (id) => {
      userId.value = id
    }
    return {
      token,
      setToken,
      userId,
      setUserId,
      username,
      setUsername
    }
  },
  {
    persist: true
  }
)
